package storage.v1;

import com.onpositive.data.IPropertyConstants;
import com.onpositive.knowledge.model.IThing;
import com.onpositive.mediawiki.dataminer.MediaWikiUniverse;
import com.onpositive.mediawiki.dataminer.WikiThing;
import com.onpositive.mediawiki.propertyparser.ParsedDocument;
import com.onpositive.mediawiki.propertyparser.PropertyCharacteristic;
import com.onpositive.semantic.model.api.meta.BaseMeta;
import com.onpositive.semantic.model.api.meta.IMeta;
import com.onpositive.semantic.model.api.property.IProperty;
import com.onpositive.units.ParsedString;

public class ActualityIndicationProperty implements IProperty {
	
/**
	 * 
	 */
	private static final long serialVersionUID = 3584303699633682324L;

	public static final String PROPERTY_NAME = "actuality-indication-property-metadata" ;
	
	private BaseMeta meta ;
	private MediaWikiUniverse universe ;
	
	public ActualityIndicationProperty( MediaWikiUniverse universe  )
	{
		this.universe = universe ;
		meta = new BaseMeta() ;
		meta.putMeta( PropertyCharacteristic.CHAR_PARSER_ID_LABEL, ParsedString.ID ) ;
		meta.putMeta(PropertyCharacteristic.CHAR_PROPERTY_NAME_LABEL, PROPERTY_NAME );
		meta.putMeta(IPropertyConstants.CHAR_IS_SERVICE_PROPERTY, true );
	}

	@Override
	public IMeta getMeta() {

		return meta;
	}

	@Override
	public String getId() {

		return PROPERTY_NAME;
	}

	@Override
	public Object getValue(Object obj)
	{	
		
		if( !(obj instanceof WikiThing) )
			return null ;
		
		String id = ( (IThing) obj ).getId();		
		ParsedDocument pd = universe.getParsedDocument(id) ;
		if( pd == null )
			return null ;
		
		boolean actual = pd.isActual();
		if (!actual){
			System.out.println("A");
		}
		return actual ? null : new ParsedString( "false", "ActualityIndicationProperty" ) ;
	}

}
